package com.ruoyi.tccs.tccs_vs_estimate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tccs.tccs_vs_estimate.domain.TccsVsEstimate;
import com.ruoyi.tccs.tccs_vs_estimate.service.ITccsVsEstimateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Vs诊断值参考Controller
 *
 * @author RenZhengYang
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/tccs/tccs_vs_estimate")
public class TccsVsEstimateController extends BaseController
{
    @Autowired
    private ITccsVsEstimateService tccsVsEstimateService;

    /**
     * 查询Vs诊断值参考列表
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_vs_estimate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TccsVsEstimate tccsVsEstimate)
    {
        startPage();
        List<TccsVsEstimate> list = tccsVsEstimateService.selectTccsVsEstimateList(tccsVsEstimate);
        return getDataTable(list);
    }

    /**
     * 导出Vs诊断值参考列表
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_vs_estimate:export')")
    @Log(title = "Vs诊断值参考", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TccsVsEstimate tccsVsEstimate)
    {
        List<TccsVsEstimate> list = tccsVsEstimateService.selectTccsVsEstimateList(tccsVsEstimate);
        ExcelUtil<TccsVsEstimate> util = new ExcelUtil<TccsVsEstimate>(TccsVsEstimate.class);
        util.exportExcel(response, list, "Vs诊断值参考数据");
    }

    /**
     * 获取Vs诊断值参考详细信息
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_vs_estimate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tccsVsEstimateService.selectTccsVsEstimateById(id));
    }

    /**
     * 新增Vs诊断值参考
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_vs_estimate:add')")
    @Log(title = "Vs诊断值参考", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TccsVsEstimate tccsVsEstimate)
    {
        tccsVsEstimate.setCreateBy(getUsername());
        return toAjax(tccsVsEstimateService.insertTccsVsEstimate(tccsVsEstimate));
    }

    /**
     * 修改Vs诊断值参考
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_vs_estimate:edit')")
    @Log(title = "Vs诊断值参考", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TccsVsEstimate tccsVsEstimate)
    {
        tccsVsEstimate.setUpdateBy(getUsername());
        return toAjax(tccsVsEstimateService.updateTccsVsEstimate(tccsVsEstimate));
    }

    /**
     * 删除Vs诊断值参考
     */
    @PreAuthorize("@ss.hasPermi('tccs:tccs_vs_estimate:remove')")
    @Log(title = "Vs诊断值参考", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tccsVsEstimateService.deleteTccsVsEstimateByIds(ids));
    }
}
